﻿<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
    <meta charset="utf-8">
    <title>Evara - 网上购物商城</title>
<!--    <script src="../../../../console-ban.min.js"></script>-->
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta property="og:title" content="">
    <meta property="og:type" content="">
    <meta property="og:url" content="">
    <meta property="og:image" content="">
    <link rel="shortcut icon" type="image/x-icon" href="../../imgs/theme/favicon.svg">
    <link rel="stylesheet" href="../../css/main.css?v=3.4">
</head>
<body>
<header class="header-area header-style-4 header-height-2">
    <div class="header-bottom header-bottom-bg-color sticky-bar">
        <div class="container">
            <div class="header-wrap header-space-between position-relative">
                <div class="logo logo-width-1 d-block d-lg-none">
                    <a href="/url/index"><img src="../../imgs/theme/logo.svg" alt="logo"></a>
                </div>
                <div class="header-nav d-none d-lg-flex">
                    <div class="main-menu main-menu-padding-1 main-menu-lh-2 d-none d-lg-block">
                        <nav>
                            <ul>
                                <li><a class="active" href="/url/promanage">管理员主页 <i class="fi-rs-angle-down"></i></a>
                                    <ul class="sub-menu">
                                        <li><a href="/url/promanage">商品管理</a></li>
                                        <li><a href="/url/usermanage">用户管理</a></li>
                                        <li><a href="/url/ordermanage">订单管理</a></li>
                                        <li><a href="/url/login">退出登录</a></li>
                                    </ul>
                                </li>
                            </ul>
                        </nav>
                    </div>
                </div>
            </div>
        </div>
    </div>
</header>
<main class="main">
    <div class="page-header breadcrumb-wrap">
        <div class="container">
            <div class="breadcrumb">
                <a href="/url/promanage" rel="nofollow">管理员主页</a>
                <span></span> 订单管理
            </div>
        </div>
    </div>
    <section class="mt-50 mb-50">
        <div class="container">
            <form id="info-form">
                <div class="row">
                    <div class="form-group col-md-6">
                        <label>订单id</label>
                        <input required="" class="form-control square" name="orderid" id="orderid" readonly placeholder="订单id" v-model="orderid"
                               type="text" :value="order != null ? order.orderid : ''">
                    </div>
                    <div class="form-group col-md-6">
                        <label>用户</label>
                        <input required="" class="form-control square" name="username" placeholder="用户" readonly
                               type="text" :value="order != null && order.user != null ? order.user.realname : ''">
                    </div>
                    <div class="form-group col-md-6">
                        <label>实际付款金额</label>
                        <input required="" class="form-control square" name="payment" readonly placeholder="实际付款金额"
                               type="text" :value="order != null ? order.payment : ''">
                    </div>
                    <div class="form-group col-md-6">
                        <label>订单状态</label>
                        <select class="form-control" name="status" id="status" v-model="status">
                            <option value="0">已取消</option>
                            <option value="20">已付款</option>
                            <option value="40">已发货</option>
                            <option value="50">交易成功</option>
                            <option value="60">交易关闭</option>
                        </select>
                    </div>
                    <div class="col-md-12">
                        <button type="button" class="btn btn-fill-out submit"
                                name="submit" value="Submit" v-on:click="saveOrder()">保存
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </section>
</main>
<div id="preloader-active">
    <div class="preloader d-flex align-items-center justify-content-center">
        <div class="preloader-inner position-relative">
            <div class="text-center">
                <h5 class="mb-5">Now Loading</h5>
                <div class="loader">
                    <div class="bar bar1"></div>
                    <div class="bar bar2"></div>
                    <div class="bar bar3"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../../js/vendor/modernizr-3.6.0.min.js"></script>
<script src="../../js/vendor/jquery-3.6.0.min.js"></script>
<script src="../../js/vendor/jquery-migrate-3.3.0.min.js"></script>
<script src="../../js/vendor/bootstrap.bundle.min.js"></script>
<script src="../../js/plugins/slick.js"></script>
<script src="../../js/plugins/jquery.syotimer.min.js"></script>
<script src="../../js/plugins/wow.js"></script>
<script src="../../js/plugins/jquery-ui.js"></script>
<script src="../../js/plugins/perfect-scrollbar.js"></script>
<script src="../../js/plugins/magnific-popup.js"></script>
<script src="../../js/plugins/select2.min.js"></script>
<script src="../../js/plugins/waypoints.js"></script>
<script src="../../js/plugins/counterup.js"></script>
<script src="../../js/plugins/jquery.countdown.min.js"></script>
<script src="../../js/plugins/images-loaded.js"></script>
<script src="../../js/plugins/isotope.js"></script>
<script src="../../js/plugins/scrollup.js"></script>
<script src="../../js/plugins/jquery.vticker-min.js"></script>
<script src="../../js/main.js?v=3.4"></script>
<script src="../../js/shop.js?v=3.4"></script>
<script src="../../js/vue.global.js"></script>
<script src="../../js/axios.min.js"></script>
</body>
<script>
    const app = {
        data() {
            return {
                order: {}
            }
        },
        methods: {
            saveOrder: function () {
                if (confirm("确认保存该条记录吗？")) {
                    let data = {
                        orderid: this.orderid,
                        status: this.status
                    }
                    axios.post('/order/update', data)
                        .then((response) => {
                            if (response.data.code == 200) {
                                alert('保存成功')
                                setTimeout(location.href = '/url/ordermanage', 2000);
                            } else {
                                alert('保存失败')
                            }
                        })
                        .catch((error) => {
                            console.error(error);
                            alert('保存失败')
                        })
                }
            },
        },
        created() {
            let searchstr = location.search
            if (searchstr != '') {
                let params = new URLSearchParams(location.search);
                let id = params.get('id')
                let _this = this
                axios.get('/order/'+id)
                    .then((response) => {
                        _this.order = response.data.data
                        _this.orderid = _this.order.orderid
                        _this.status = _this.order.status
                    })
                    .catch((error) => {
                        console.error(error);
                        alert('初期化错误')
                    })
            }
        }
    }
    Vue.createApp(app).mount('body')
</script>
</html>